#ifndef __Info_To_Wave_
#define __Info_To_Wave_

#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <boost/serialization/vector.hpp>
#include <string>
#include <iostream>
#include <fstream>
#include <vector>

using std::string;
using std::vector;

struct lbar_struct_IW {
  int lbar;
  int lbar12;
  int lbar3;
};

struct l_struct_IW {
  int l12p;
  int l12;
  int l3p;
  int l3;
};

class Info_Wave{
public:
  int n_max;
  int l_max;
  int lbar123_max;
  vector<l_struct_IW> l_state;
  vector<vector<vector<vector<int>>>> l_vec; //[l12p][l12][l3p][l3]
  vector<lbar_struct_IW> lbar_state;   // lbar lbar12 lbar3
  vector<vector<vector<int>>> lbar_vec; // lbar_vec[lbar][lbar12][lbar3]
  vector<vector<int>> E_Jac_conf;
  vector<vector<int>> Llbar_Ic_Reduced;
  vector<vector<int>> Llbar_Ic_Red_vec;
};

namespace boost {
  namespace serialization {
    template<class Archive>
      void serialize(Archive &ar, lbar_struct_IW &a, const unsigned int version){
      ar & a.lbar;
      ar & a.lbar12;
      ar & a.lbar3;
    }
    template<class Archive>
      void serialize(Archive &ar, l_struct_IW &a, const unsigned int version){
      ar & a.l12p;
      ar & a.l12;
      ar & a.l3p;
      ar & a.l3;
    }
    template<class Archive>
      void serialize(Archive &ar, Info_Wave &a, const unsigned int version){
      ar & a.n_max;
      ar & a.l_max;
      ar & a.lbar123_max;
      ar & a.l_state;
      ar & a.l_vec;
      ar & a.lbar_state;
      ar & a.lbar_vec;
      ar & a.E_Jac_conf;
      ar & a.Llbar_Ic_Reduced;
      ar & a.Llbar_Ic_Red_vec;
    }
  }
};

class Serial_SL_IW{
  // serial control Save & Load
 public:
   //~~~~~~~~~~~~~~~~~~~For com_sparse_row.h save~~~~~~~~~~~~~~~~~~~~~~~~~//
   void save(Info_Wave &A, string filename){
     std::ofstream ofs(filename);
     // save data to archive
     boost::archive::binary_oarchive oa(ofs);
     // write class instance to archive
     oa << A;
   }
   void load(Info_Wave &A, string filename){
     std::ifstream ifs(filename);
     // save data to archive
     boost::archive::binary_iarchive ia(ifs);
     // write class instance to archive
     ia >> A;
   }
 };

#endif
